package com.macro.mall.controller;

import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.BmsMuseumApplicantDetail;
import com.macro.mall.dto.BmsMuseumApplicantParam;
import com.macro.mall.model.BmsMuseumApplicant;
import com.macro.mall.service.BmsMuseumApplicantService;
import com.macro.mall.utils.ExcelUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.List;

@Controller
@Api(tags = "BmsMuseumApplicantController")
@Tag(name = "BmsMuseumApplicantController", description = "文博项目-报名")
@RequestMapping("/museumApplicant")
public class BmsMuseumApplicantController {

    @Autowired
    private BmsMuseumApplicantService bmsMuseumApplicantService;

    @ApiOperation("分页查询文博项目-报名")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<BmsMuseumApplicant>> getList(@RequestBody BmsMuseumApplicantParam bmsMuseumApplicantParam) {
        List<BmsMuseumApplicant> bmsMuseumApplicantList = bmsMuseumApplicantService.getList(bmsMuseumApplicantParam);
        return CommonResult.success(CommonPage.restPage(bmsMuseumApplicantList));
    }

    @ApiOperation("根据id获取文博项目-报名信息")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<BmsMuseumApplicantDetail> getItem(@PathVariable Long id) {
        BmsMuseumApplicantDetail bmsMuseumApplicantDetail = bmsMuseumApplicantService.getItem(id);
        return CommonResult.success(bmsMuseumApplicantDetail);
    }

    @ApiOperation("根据团队id修改人员报名状态")
    @RequestMapping(value = "/updateStatusByMuseumTeamId", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> updateStatusByMuseumTeamId(@RequestBody BmsMuseumApplicant bmsMuseumApplicant) {
        int result = bmsMuseumApplicantService.updateStatusByMuseumTeamId(bmsMuseumApplicant);
        return CommonResult.success(result);
    }

    @ApiOperation("文件导出")
    @RequestMapping(value = "/export", method = RequestMethod.POST)
    public void export(@RequestBody BmsMuseumApplicantParam bmsMuseumApplicantParam, HttpServletResponse response) throws Exception {
        bmsMuseumApplicantService.getExporttList(bmsMuseumApplicantParam,response);
    }


}
